<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        canvas {
            width: 100%;
            height: 100%;
            border: 1px solid black;
    </style>
    <script src="./pdfjs/pdf.js" type="text/javascript"></script>
    <script src="getUrlParam.js" type="text/javascript"></script>
    <script type="text/javascript">
			function showPdf()
            {
		            var container = document.getElementById("container");
		            var url= UrlParm.parm("pdfpath");
		    	    //以下两行代码解决不能显示中文的问题	
		            PDFJS.cMapUrl= 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.0.288/cmaps/'
		            PDFJS.cMapPacked= true
		    
		            PDFJS.workerSrc = './pdfjs/pdf.worker.js';
		            PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf) {
		                for (var i = 1; i < pdf.numPages+1; i++) {
		                    pdf.getPage(i).then(function getPageHelloWorld(page) {
		                        var scale = 3.0;
		                        var viewport = page.getViewport(scale);
		                        var canvas = document.createElement('canvas');
		                        var context = canvas.getContext('2d');
		                        canvas.height = viewport.height;
		                        canvas.width = viewport.width;
		                        // 这里拿body当pdf容器
		                        document.body.appendChild(canvas);
		                        page.render({ canvasContext: context, viewport: viewport });
		                    });
		                }
		            });
			}

    </script>
</head>
<body onload="showPdf()">
</body>
</html>
